<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>XSD朗读吧——登录</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/common.css">
<script src="js/jquery-1.9.1.js"></script>
<body>
<div class="Header"><a href="">XSD朗读吧</a></div>

<h1>用户登录<sup>V2017</sup></h1>

<div class="login" style="margin-top:50px;">

    <div class="web_qr_login" id="web_qr_login" style="display: block; height: 235px;">
        <!--登录-->
        <div class="web_login" id="web_login">
            <div class="login-box">
                <div class="login_form">
                        <div class="uinArea" id="uinArea">
                            <label class="input-tips" for="u">卡号：</label>
                            <div class="inputOuter" id="uArea">

                                <input type="text" id="cardno" name="cardno" class="inputstyle"/>
                            </div>
                        </div>
                        <div class="pwdArea" id="pwdArea">
                            <label class="input-tips" for="p">密码：</label>
                            <div class="inputOuter" id="pArea">

                                <input type="password" id="passwd" name="passwd" class="inputstyle"/>
                            </div>
                        </div>
						<div class="form-group" style="text-align: center;">
							<span id="info" style="margin:0 auto;"></span>
						</div>
                        <div style="padding-left:50px;margin-top:20px;"><input onclick="Login()" type="submit" value="登 录" style="width:150px;" class="button_blue"/></div>
                </div>

            </div>

        </div>
        <!--登录end-->
    </div>
</div>

<!--底部-->
<div class="footer">
    信昇达—朗读亭
</div>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script type="text/javascript">
$("#cardno").focus();
document.onkeydown = function(event) {
	var e = event || window.event
			|| arguments.callee.caller.arguments[0];
	if (e && e.keyCode == 13) { // enter 键
		Login();
	}
};
	function Login() {
		var cardno = $("#cardno").val();
		var strpasswd = $("#passwd").val();
		if (cardno.length <= 0 || strpasswd.length <= 0) {
			ShowMsg('#info', "密码或用户名不能为空！", 'red');
		} else {
			CheckLogin(cardno, strpasswd);
		}
	}
	function ShowMsg(id, strmsg, strcolor) {
		$(id).css('color', strcolor);
		$(id).html(strmsg);

		for ( var i = 0; i < 2; i++) {
			$(id).fadeOut(200);
			$(id).fadeIn(200);
		}
	}
	//登录
	function CheckLogin(cardno, strpasswd) {
		var strurl = "usercenter/login?cardno=" + cardno + "&passwd="
				+ hex_md5(strpasswd);
		$.ajax({
			type : "POST",
			url : strurl,
			success : function(data) {
				if (data == "OK") {
					top.location.href = "usercenter";
					return true;
				} else {
					ShowMsg('#info', "密码或者用户名错误！", 'red');
					return false;
				}
			}
		});
	}
</script>
</body>
</html>